
import Home from '@/pages/Home'
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
export default[
    // show是否展示footer组件
    {
        path:'/center',
        name:"center",
        component:()=>import("@/pages/Center"),
        meta:{
            show:true,
        },
        //知道如何使用即可
        // children:[
        //     {
        //         path:"/center/myOrder",
        //         component:myOrder
        //     },
        //     {
        //         path:"/center/groupOrder"
        //     },
        //     {
        //         path:"/center",
        //         redirect:"/center/myOrder"
        //     }
        // ]                                               
    },
    {
        path:'/paySuccess',
        name:"paySuccess",
        component:()=>import("@/pages/PaySuccess"),
        meta:{
            show:true,
        },
        beforeEnter: (to, from, next) => {
            if(from.path){
                next();
            }else{
                next(false);
            }
        }
    },
    {
        path:'/pay',
        name:"pay",
        component:()=>import("@/pages/Pay"),
        meta:{
            show:true,
        },
        beforeEnter: (to, from, next) => {
            if(from.path=="/trade"){
                next();
            }else{
                next(false);
            }
        }
    },
    {
        path:'/trade',
        name:"trade",
        component:()=>import("@/pages/Trade"),
        meta:{
            show:true,
        },
        beforeEnter: (to, from, next) => {
            if(from.path=="/shopCart"){
                next();
            }else{
                next(false);
            }
        }
    },
    {
        path:'/shopCart',
        name:"shopCart",
        component:()=>import("@/pages/ShopCart"),
        meta:{
            show:true
        }
    },
    {
        path:'/addcartsuccess',
        name:"addcartsuccess",
        component:()=>import("@/pages/AddCartSuccess"),
        meta:{
            show:true
        },
        // beforeEnter: (to, from, next) => {
        //     if(from.path=="/detail"){
        //         next();
        //     }else{
        //         next(false);
        //     }
        // }
    },
    {
        path:'/detail/:skuId?',
        name:"detail",
        component:()=>import("@/pages/Detail"),
        meta:{
            show:true
        },
        // beforeEnter: (to, from, next) => {
        //     if(from.path=="/search"){
        //         next();
        //     }else{
        //         next(false);
        //     }
        // }
    },
    {
        path:'/home',
        name:"home",
        component:()=>import("@/pages/Home"),
        meta:{
            show:true
        }
    },
    {
        name:"search",
        path:'/search/:keyword?',
        component:()=>import("@/pages/Search"),
        meta:{
            show:true
        },
        // props:($route)=>{
        //     return{
        //         k:$route.params.k,
        //         keyWords:$route.query.keyWords
        //     };
        // }
    },
    {
        path:'/login',
        name:"login",
        component:()=>import("@/pages/Login"),
        meta:{
            show:false
        }
    },
    {
        path:'/register',
        name:'register',
        component:()=>import("@/pages/Register"),
        meta:{
            show:false
        }
    },
    {
        path:'/',
        redirect:"/home"
    }

]
